package com.popcorn.board.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.popcorn.action.Action;
import com.popcorn.action.ActionForward;
import com.popcorn.board.dao.BoardDAO;
import com.popcorn.board.model.BoardModel;

public class BoardDeleteAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		BoardDAO BoardDAO = new BoardDAO();
		BoardModel BoardModel = new BoardModel();
		ActionForward forward = new ActionForward();
		int idx = Integer.parseInt(request.getParameter("idx"));
   		boolean result=false;
   		
   		try{	
   			BoardModel.setTITLE(request.getParameter("TITLE"));
   			BoardModel.setCONTENT(request.getParameter("CONTENT"));
   			BoardModel.setREG_DTM(request.getParameter("REG_DTM"));
   			BoardModel.setREG_ID(request.getParameter("REG_ID"));
   			BoardModel.setFIELD(request.getParameter("FIELD"));  			

   			result=BoardDAO.modelDelete(idx);
   			System.out.println("============BoardDeleteAction============");
   			System.out.println("1."+request.getParameter("REG_DTM"));
	   		if(result==false){
	   			System.out.println("DB ?�록 ?�패");
	   			return null;
	   		}
	   		System.out.println("DB ?�록 ?�공");
	   		
	   		forward.setRedirect(true);
	   		forward.setPath("BoardListDB.zo"); 
	   		return forward;
	   		
  		}catch(Exception ex){
   			ex.printStackTrace();
   		}
		
		return null;
	}

}
